<?php

class User_Model_User extends Account_Model_Account
{
	//TODO: move these out of here!

	public function getUrl($params=NULL)
	{
		return '/user/'. $this->getIdName();
	}

	/**
	 * Check the access to an object associated to this object
	 */
	public function userHasObjectAccess($accountId, $objClassIdName, $objId, $accessName)
	{
		//TODO: load these from db
		switch ($objClassIdName) {
		case 'note':
			switch ($accessName) {
			case 'GET': return TRUE;
			case 'GET-comment': return TRUE;
			case 'PUT-comment': return TRUE;
			default: return FALSE;
			}
		case 'wall':
			switch ($accessName) {
			case 'GET': return TRUE;
			case 'PUT': return User_Model_RelationshipMap::has($this->getId(), $accountId, 'friend', TRUE);
			case 'PUT-comment': return User_Model_RelationshipMap::has($this->getId(), $accountId, 'friend', TRUE)
				|| $this->getId() == $accountId;
			default: return FALSE;
			}
		}
		return FALSE;
	}
}
